const STORAGE_KEYS = {
  currentUser: 'currentUser',
  cases: 'cases',
  lawyers: 'lawyers',
  shares: 'shares'
}

function load(key, defaultValue = null) {
  try {
    const value = uni.getStorageSync(key)
    return value !== '' ? value : defaultValue
  } catch (e) {
    console.error('Storage load error:', e)
    return defaultValue
  }
}

function save(key, value) {
  try {
    uni.setStorageSync(key, value)
  } catch (e) {
    console.error('Storage save error:', e)
  }
}

function remove(key) {
  try {
    uni.removeStorageSync(key)
  } catch (e) {
    console.error('Storage remove error:', e)
  }
}

module.exports = {
  load,
  save,
  remove,
  STORAGE_KEYS
}
